package digui;

public class MaxAndMin {
    public static void main(String[] args) {
        int arr[] = {1,2,3,5,4,9};
        swap swap = new swap();
        int i = swap.swap1(arr, arr.length);
        System.out.println(i);
        int i1 = swap.swap2(arr, arr.length);
        System.out.println(i1);
    }
}
class swap{
    public static int  swap1(int arr[],int n){
        if(n==0){
            return arr[0];
        }else {
          return arr[n - 1] > swap1(arr, n - 1) ? arr[n - 1] : swap1(arr, n - 1);
        }
    }
    public static int  swap2(int arr[],int n){
        if(n==0){
            return arr[0];
        }else {
            return arr[n - 1] < swap2(arr, n - 1) ? arr[n - 1] : swap2(arr, n - 1);
        }
    }
}
